package junittest;

public class NextDate {
    public static String cal(int y, int m, int d){
        if (y < 1900 || y > 2050 || m < 1 || m > 12 || d < 1 || d > 31){
            return "输入错误";
        }else if ((m == 4 || m == 6 || m == 9 || m == 11) && d > 30){
            return "输入错误";
        }else if (IsLeapYear.judge(y) == false && m == 2 && d > 28){
            return "输入错误";
        }else if (IsLeapYear.judge(y) == true && m == 2 && d > 29){
            return "输入错误";
        }else {
            String str;
            if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 30){
                m = m + 1;
                d = 1;
            }else if(IsLeapYear.judge(y) == false && m == 2 && d == 28){
                m = m + 1;
                d = 1;
            }else if(IsLeapYear.judge(y) == true && m == 2 && d == 29){
                m = m + 1;
                d = 1;
            }else if ((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10) && d == 31){
                m = m + 1;
                d = 1;
            }else if (m == 12 && d == 31){
                y = y + 1;
                m = 1;
                d = 1;
            }
            else {
                d = d + 1;
            }
            str = String.format("%1$d年%2$d月%3$d日", y, m, d);
            return str;
        }
//        return "无法判断";
    }
}
